Skip to content

Add Moonshot adapter for kimi-k2.5#26

Closed
ChiragAgg5k wants to merge 1 commit intomainfrom
feat/moonshot-kimi-k2-5-adapter
Closed

Add Moonshot adapter for kimi-k2.5#26
ChiragAgg5k wants to merge 1 commit intomainfrom
feat/moonshot-kimi-k2-5-adapter

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

  • add a new Moonshot adapter targeting Moonshot's OpenAI-compatible chat completions API
  • support kimi-k2.5 with Moonshot-specific request behavior and JSON-mode structured output
  • document the provider and add a conversation test scaffold using LLM_KEY_MOONSHOT

Verification

  • php -l src/Agents/Adapters/Moonshot.php
  • php -l tests/Agents/Conversation/ConversationMoonshotTest.php
  • vendor/bin/pint --test src/Agents/Adapters/Moonshot.php tests/Agents/Conversation/ConversationMoonshotTest.php
  • vendor/bin/phpstan analyse --level max --debug src/Agents/Adapters/Moonshot.php tests/Agents/Conversation/ConversationMoonshotTest.php

Notes

  • A broader PHPUnit run still hits two existing Ollama network failures in AgentTest (Could not resolve host: ollama).
  • The live Moonshot conversation test was added but not executed here because LLM_KEY_MOONSHOT was not set in this environment.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR adds a Moonshot adapter targeting the kimi-k2.5 model via Moonshot's OpenAI-compatible API, along with documentation and a test scaffold. The implementation is functionally sound and follows the existing adapter patterns, but has two notable maintenance concerns in Moonshot.php.

  • Moonshot::send() is almost entirely a verbatim copy of OpenAI::send() (the three actual differences are: schema embedded in system prompt text rather than json_schema transport, response_format using json_object, and temperature omitted from the payload instead of being reset to 1.0). Because the class already inherits from OpenAI, future fixes or enhancements to the parent's send() will silently diverge from Moonshot.
  • usesMaxCompletionTokens() is overridden to return true, but this method is only consulted by OpenAI::send(), which is never reached because Moonshot::send() replaces it entirely. The override is therefore dead code and may mislead future maintainers.
  • The test scaffold correctly reads LLM_KEY_MOONSHOT from the environment and delegates all assertions to ConversationBase.
  • The README additions are clear and accurate.

Confidence Score: 4/5

  • Safe to merge; no runtime bugs found, but the adapter carries maintenance debt from send() duplication.
  • The adapter is functionally correct and consistent with how other OpenAI-compatible adapters (e.g. Deepseek) are structured. The two flagged issues — send() duplication and a dead usesMaxCompletionTokens() override — are maintenance concerns rather than runtime errors, hence a score of 4 rather than 5.
  • src/Agents/Adapters/Moonshot.php — review the send() duplication and the unreachable usesMaxCompletionTokens() override.

Important Files Changed

Filename Overview
src/Agents/Adapters/Moonshot.php New Moonshot adapter extending OpenAI; functionally correct but send() is nearly a full duplication of the parent, and usesMaxCompletionTokens() is dead code because the overridden send() never calls it.
tests/Agents/Conversation/ConversationMoonshotTest.php Standard conversation test scaffold following the existing pattern; correctly delegates to ConversationBase and reads the API key from the environment variable LLM_KEY_MOONSHOT.
README.md Documents the new Moonshot provider with a usage example and notes on JSON-mode structured output behaviour; no issues found.

Reviews (1): Last reviewed commit: "Add Moonshot adapter for kimi-k2.5" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant